home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Pascal / Snippets / CopyBits Demo / ReadMe < prev   
Encoding:
Text File  |  1995-10-23  |  3.7 KB  |  85 lines  |  [TEXT/ttxt]

  1.  
  2.  CopyBits Demo.p
  3.  
  4.  Implemented in Oct 1995 using Metrowerks CW6.
  5.  Converted from C code written in May 1995 using 
  6.  Metrowerks CodeWarrior v5.
  7.  
  8.  This Pascal CopyBits Demo project v3.1P is by Bill Catambay.
  9.  The orginal C CopyBits Demo project v3.1 was by Kenneth Worley.
  10.  
  11.  This code is Copyright 1995. All Rights Reserved.
  12.  You may use this code in any project of your own. You may also
  13.  redistribute this project to anyone else as long as 1) all the
  14.  project files (including documentation files) are kept together,
  15.  and 2) nothing is charged for the project.
  16.  
  17.  I really don't know what the rules are for C code converted to
  18.  Pascal as far as permission, licensing, and all that garbage.
  19.  If you have any information to shed light on this subject for me,
  20.  please E-mail me at Catambay@aol.com (and I thank you in advance).
  21.  
  22. Worley notes:
  23.  This is a tutorial project that demonstrates the use of
  24.  CopyBits and offscreen Graphics Worlds (GWorlds). It shows
  25.  several instances of copying images to and from offscreen
  26.  graphics worlds using CopyBits, provides several macros that
  27.  make the process a little easier, shows an example of
  28.  drawing into an offscreen graphics world and how that can
  29.  improve onscreen animation, and it demonstrates a "fade"
  30.  using CopyBits to fade a portion of the screen to black.
  31.  
  32.  In a nutshell, the app puts up a dialog that shows two
  33.  "source" pictures (1 & 2) and a destination area. Clicking
  34.  on the "Copy" buttons above each of the source pictures
  35.  causes the picture to be copied to the destination area.
  36.  Picture 1 is labelled as "flickery animation" and picture 2
  37.  is labelled as "smooth animation." When you put the cursor
  38.  over each picture, you should see a difference in how a
  39.  colored circle is animated over the picture. You should
  40.  occasionally see the background "flicker" through on
  41.  picture 1, but not on picture 2 because it uses an
  42.  intermediary GWorld to draw in.
  43.  
  44.  The Fade to black button over the destination area will
  45.  cause that area to fade to black from whatever happens to
  46.  be in there. It does this by repeatedly copying a gray
  47.  rectangle from a GWorld into the destination area using
  48.  the subPin transfer mode of CopyBits. The erase button
  49.  erases the destination area.
  50.  
  51.  The Fade picture buttons cause the picture under the
  52.  button to be faded into whatever is currently in the
  53.  destination area. This is accomplished using CopyBits'
  54.  blend transfer mode.
  55.  
  56. Conversion notes:
  57.    Of course, all the standard C to Pascal translation stuff
  58.    applies.  Additionally, there are some pointer stuff I had to
  59.    tweak to get this working in Pascal.  I also had to play with
  60.    the RGBColor records sometimes, because in Pascal they are treated
  61.    as integers, but in C they are treated as unsigned (I'm talking
  62.    about the components of course).  
  63.  
  64.   Here's as example of C to Pascal translation which fuels my love for Pascal:
  65.  
  66.  As originally done in C:
  67.     LocalToGlobal(* (Point*) &(offscreenRect.top));
  68.     LocalToGlobal(* (Point*) &(offscreenRect.bottom));
  69.  
  70.  As translated into Pascal:
  71.     LocalToGlobal(offscreenRect.topleft);
  72.     LocalToGlobal(offscreenRect.botRight);
  73.  
  74.  Got rid of most of the C macros, converting just one of them, WinBitMap,
  75.  into a pascal function.  Also converted to pascal are three other 
  76.  C libraries.  They have been implemented as UNITs: MyAlerts, MyDialogUtils,
  77.  and MySystemUtils.  And there was some other stuff I had to do to get 
  78.  this working, but I'm too tired now to try and remember it all.  Just enjoy
  79.  the code, and I hope you learn lots of stuff!
  80.  
  81.  Questions? Comments? Praise? Criticism? Jobs? If it has
  82.  to do with the Pascal code included here, write to 
  83.  Bill Catambay at catambay@aol.com, and if it has to do with
  84.  the original C code, write to Kenneth Worley at KNEworley@aol.com.
  85.